<table class="table table-vcenter">
    <thead>
        <tr>
            <th class="text-center" style="width: 50px">#</th>
            <th>标题</th>
            <th class="d-none d-sm-table-cell" style="width: 30%">时间</th>
            <th class="text-center" style="width: 100px">点/赞/评</th>
            <th class="text-center" style="width: 100px">操作</th>
        </tr>
    </thead>
    <tbody>
        <!--{array as="statusColor" 0="primary" 1="success" 2="warning" 3="info" 4="danger" }-->
        <!--{iCMS:article:list loop="true" page="true" row="10"  userid="$ME.uid" status=[1,3]}-->
        <tr data-id="<!--{$article_list.id}-->">
            <th class="text-center" scope="row"><!--{$article_list.id}--></th>
            <td class="font-w600 font-size-sm">
                <!--{if $article_list.status!="1"}-->
                <span class="badge badge-<!--{$statusColor[$article_list.status]}--> mr-1"><!--{$article_list.statusText}--></span>
                <!--{/if}-->
                <a href="<!--{$article_list.node.url}-->" target="_blank">
                    [
                    <!--{$article_list.node.name}-->
                    ]
                </a>
                <!--{if $article_list.status!="1"}-->
                <a href="javascript:;"><!--{$article_list.title}--></a>
                <!--{else}-->
                <a href="<!--{$article_list.url}-->" target="_blank"><!--{$article_list.title}--></a>
                <!--{/if}-->
            </td>
            <td class="d-none d-sm-table-cell">
                <!--{$article_list.pubdate|date:'Y-m-d H:i:s'}-->
            </td>
            <td class="text-center">
                <!--{$article_list.hits.count}-->
                /
                <!--{$article_list.good}-->
                /
                <!--{$article_list.comment}-->
            </td>
            <td class="text-center">
                <div class="btn-group btn-group-sm">
                    <a href="<!--{iCMS:route url='ArticleUser:publish' query[id]='$article_list.id'}-->" class="btn btn-light"><i class="fa fa-fw fa-pencil-alt"></i></a>
                    <a i="event:ArticleUser:delete" href="<!--{iCMS:route url='ArticleUser'}-->" class="btn btn-light"><i class="fa fa-fw fa-trash-alt"></i></a>
                </div>
            </td>
        </tr>
        <!--{/iCMS}-->
    </tbody>
    <tfoot>
        <tr>
            <td colspan="6">
                <nav aria-label="Page navigation">
                    <ul class="pagination push justify-content-end">
                        <!--{$iCMS.PAGE.NAV}-->
                    </ul>
                </nav>
            </td>
        </tr>
    </tfoot>
</table>
<script>
    function event_ArticleUser_delete(self, vars, e) {
        if (!confirm("确定要删除")) {
            return false;
        }
        var $self = $(self);
        var $wrap = $self.closest("[data-id]");
        var $id = $wrap.data("id");
        var api = $self.attr("href");
        var data = {
            action:'delete',
            id: $id
        };
        iCMS.request
            .post(api, data)
            .then(function (json) {
                if (json.code) {
                    iCMS.notify.success(json.message);
                    $wrap.remove();
                } else {
                    iCMS.notify.error(json.message, 3000);
                }
            })
            .catch(function (error) {
                console.log(error);
            });
    }
</script>
